//
//  StatzTextAttachment.m
//  Statz
//
//  Created by Dave MacLachlan on 07/07/23.
//
// Copyright 2007 Google Inc.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License.  You may obtain a copy
// of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
// License for the specific language governing permissions and limitations under
// the License.
//

#import "StatzTextAttachment.h"
#import "StatzSource.h"

const int kStatzStatusTextAttachmentCoderVersion = 1;
NSString *const kStatzStatusTextAttachmentCoderVersionKey = @"kStatzStatusTextAttachmentCoderVersionKey";
NSString *const kStatzStatusTextAttachmentSourceKey = @"kStatzStatusTextAttachmentSourceKey";
@implementation StatzTextAttachment


- (id)initWithCoder:(NSCoder *)aDecoder {
  if ((self = [super initWithCoder:aDecoder])) {
    int version = [aDecoder decodeInt32ForKey:kStatzStatusTextAttachmentCoderVersionKey];
    if (version != kStatzStatusTextAttachmentCoderVersion) {
      [self release];
      return nil;
    }
    statusSource_ = [[aDecoder decodeObjectForKey:kStatzStatusTextAttachmentSourceKey] retain];
  }
  return self;
}

- (void)dealloc {
  [statusSource_ release];
  [super dealloc];
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
  [super encodeWithCoder:aCoder];
  [aCoder encodeInt32:kStatzStatusTextAttachmentCoderVersion 
               forKey:kStatzStatusTextAttachmentCoderVersionKey]; 
  [aCoder encodeObject:statusSource_ forKey:kStatzStatusTextAttachmentSourceKey];
}

- (StatzSource *)statusSource {
  return [[statusSource_ retain] autorelease];
}

- (void)setStatusSource:(StatzSource *)value {
  if (statusSource_ != value) {
    [statusSource_ autorelease];
    statusSource_ = [value retain];
  }
}
@end
